package mest.controller.hws;


import com.alibaba.fastjson.JSON;
import mest.entity.plan_productjob_purchase;
import mest.entity.plan_productjob_purchase_record;
import mest.service.hws.plan_productjob_purchaseService;
import mest.service.system.DBService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.lang.annotation.Repeatable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/plan_productjob_purchase")
public class plan_productjob_purchaseController {

    @Resource
    private plan_productjob_purchaseService ppp;
    @Autowired
    private DBService dbService;

    @RequestMapping("/insertModel")
    //批量新增plan_productjob_purchaseMapper内容表
    public int insert(@RequestBody List<plan_productjob_purchase> record) {
        System.out.println("进入控制层");
        String theirDb = dbService.getCompanyDB();
        /*/insertModel /delModel /updateByone*/
        return ppp.insert(theirDb,record);
    }


    //根据id查询单个数据
    @RequestMapping("/selectById")
    public String selectByPrimaryKey(Integer id) {
        String theirDb = dbService.getCompanyDB();
        /* selectById  selectAll  */
        return ppp.selectByPrimaryKey(theirDb,id);
    }

    //根据ppid和状态查询计划单关联的内容对象集合
    @RequestMapping("/selectAll")
    public String selectPrimary(Integer limit, Integer page, Integer ppId, Integer status) {
        String theirDb = dbService.getCompanyDB();
        return ppp.selectPrimary( theirDb,limit,  page,  ppId,  status);
    }


    //更新数量，供应商，状态
    @RequestMapping("/updateByone")
    public String updateByPrimaryKey(plan_productjob_purchase record) {
        String theirDb = dbService.getCompanyDB();
        /*/insertModel /delModel /updateByone*/
        return  ppp.updateByPrimaryKey(theirDb,record);
    }

}
